<template>
  <div>
    <el-form
      :inline="true"
      :model="formData"
      size="small"
      class="demo-form-inline"
    >
      <el-form-item prop="nickName" label="用户名">
        <el-input
          v-model="formData.nickName"
          clearable
          placeholder="用户名"
        ></el-input>
      </el-form-item>
      <el-form-item prop="mobile" label="手机号码">
        <el-input
          v-model="formData.mobile"
          clearable
          placeholder="手机号码"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="success" @click="$refs.user.show()"
          >新增用户</el-button
        >
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="tableData">
      <el-table-column prop="userName" label="用户名" width="180">
      </el-table-column>
      <el-table-column prop="mobile" label="手机号码" width="180">
      </el-table-column>
      <el-table-column prop="roleName" label="角色名称" width="180">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="180">
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button
            type="success"
            size="mini"
            @click="$refs.user.show(scope.row)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <v-pagination :formData="formData" @load="getData"></v-pagination>
    <user-Modal ref="user" @load="getData"></user-Modal>
  </div>
</template>
<script>
import { queryManagerList } from "@/api/userManagement/user";
import pagination from "@/components/pagination";
import userModal from "./modules/userModal";
export default {
  components: {
    vPagination: pagination,
    userModal
  },
  data() {
    return {
      formData: {
        userName: "",
        mobile: "",
        pageNo: 1,
        pageSize: 10,
        total: 0,
      },
      tableData: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.loading = true;
      queryManagerList(this.formData).then((res) => {
        this.loading = false;
        this.tableData = res.data.resultData.managerList;
        this.formData.total = res.data.resultData.count;
      });
    },
    onSubmit(formName) {
      this.formData.pageNo = 1;
      this.formData.pageSize = 10;
      this.formData.total = 0;
      this.getData();
    },
  },
};
</script>